a = input()
k = 0
nigga = ""
sp = []
for i in range(len(a)):
  if a[i] == "(" or a[i] == "[" or a[i] == "{" or a[i] == "<":
    sp.append(a[i])
  else:
    nigga = sp.pop()
    if not (nigga == "(" and a[i] == ")" or 
      nigga == "[" and a[i] == "]" or 
      nigga == "{" and a[i] == "}" or 
      nigga == "<" and a[i] == ">"):
      print("False")
      k = 1
      break
if len(sp) == 0 and k != 1:
  print("True")
elif len(sp) == 0:
  print("False")
